package Sci.Learn.Lambda;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class PredicateSample<T> {
    public static void main(String[] args) {
        Predicate<Integer> predicate=n->n>4;
        boolean result=predicate.test(4);
        System.out.println(result);
        PredicateSample pt=new PredicateSample();
        List<Integer> list= Arrays.asList(1,2,3,4,5,6,7,8,9);

        pt.filter(list,n->((Integer)n) %2==1);
        pt.filter(list,n->((Integer)n)%2==0);
        List<String> strlist=Arrays.asList("java","python","php","HTML");

        pt.filter(strlist,n->n.toString().contains("a"));
    }
    public  void filter(List<T> list, Predicate<T> predicate)
    {
        list.forEach(li->{
            if (predicate.test(li)) {
                System.out.print(li+" ");
            }
            });
        System.out.println("");
    }


}
